\section{ocamlgraph}
\label{sec:ocamlgraph}

\textit{ocamlgraph} is a sex library which deserve well-documentation.

Check the file \textit{pack.ml}, it provides a succint interface.

\begin{ocamlcode}
  module Digraph = Generic(Imperative.Digraph.AbstractLabeled(I) (I))
  module Graph = Generic(Imperative.Graph.AbstractLabeled(I) (I))
\end{ocamlcode}

The Imperative implementation is in \textit{imperative.ml}, 

A nice trick, to bind open command to use graphviz to open the file,
then it will do the sync up automatically

\inputminted[fontsize=\scriptsize
]{ocaml}{code/graph/dag.ml}
\captionof{listing}{Play with DAG  \label{DAG}}

Different modules have corresponding algorithms
\textit{Graph.Pack} requires its label being integer 



\subsection{Undirected graph}
\label{sec:undirected-graph}

so, as soon as you want to label your vertices with strings and your
edges with floats, you should use functor. Take
\textit{ConcreteLabeled} as an example


\inputminted[fontsize=\scriptsize
]{ocaml}{code/graph/concrete.ml}
\captionof{listing}{Play with Labelled DAG  \label{DAG}}

\textit{Graphviz.Dot} and \textit{Graphviz.Neato} are used to output a
dot file.


here is a useful example to visualize the output generated by ocamldep.

\subsection{Example Visualize Dependency}
\label{sec:Visualize}

\inputminted[fontsize=\scriptsize
]{ocaml}{code/graph/dep.ml}
\captionof{listing}{Visualize Dependency  \label{ocamldep}}






%%% Local Variables: 
%%% mode: latex
%%% TeX-master: "../master"
%%% End: 
